#include <global.h>
#include <kdtree2.hpp>
#include <vector>

typedef CGAL::Creator_uniform_2<double,Point>  Creator;
Point random_point()
{
	//Return a point in the range of [0,1]x[0,1] uniformly
	static CGAL::Random r1;
	static CGAL::Random r2;
	double x = r1.get_double();
	double y = r2.get_double();
	return Point(x,y);
}

int find_nearest (std::vector<Point> & v_p, Point & r_p)
{
	int index = -1;
	double distance = 100;
	for (int i = 0; i < v_p.size(); ++i)
	{
		double length = (r_p - v_p[i]).squared_length(); 
		if ( length < distance )
		{
			distance = length; 
			index = i; 
		}
	}
	assert (index != -1);
	return index ; 

}
int move_point (std::vector<Point> & v_p, int n_index, Point & r_p)
{
//double x = 
}
int main()
{
	int numbound;
	Polygon bound;
	std::vector<Point> v_p;
	std::cin>>numbound;
	for (int i = 0; i < numbound; ++i)
	{
		Point p;
		std::cin>>p;
		bound.push_back(p);
	}
	
	int numseeds;
	std::cin>>numseeds;
	for (int i = 0; i < numseeds; ++i)
	{
		Point p;
		std::cin>>p;
		v_p.push_back(p);
	}

	std::vector<int > v_weight;
	for (int i = 0; i < numseeds; ++i)
	{
		v_weight.push_back(1);
	}


	std::vector<Point> points;
	CGAL::Random_points_in_square_2  <Point, Creator> g (0.5);
	CGAL::copy_n (g , 1e6, std::back_inserter(points));

	
	for (int i = 0; i < points.size(); ++i)
	{
		points[i] = Point (points[i].x() + 0.5, points[i].y() + 0.5);
		//cout<<points[i]<<endl;
	}
	for (int i = 0; i < points.size(); ++i)
	{
		//std::cout<<points[i]<<std::endl;;
		int index = find_nearest (v_p, points[i]);
		
		//move_point(v_p, index, points[i]);
		double x = ( v_weight[index] * v_p[index].x() + points[i].x() ) / (DOUBLE(v_weight[index]) + 1.0);
		double y = ( v_weight[index] * v_p[index].y() + points[i].y() ) / (DOUBLE(v_weight[index]) + 1.0);
		v_p[index] = Point(x,y);
		v_weight[index]++;
    }

	for (int i = 0; i < v_p.size(); ++i)
	{
		cout<<v_p[i]<<" 0" <<endl;
	}

	

	//cout<<"Hello Macqueen"<<endl;
	return 0;
}
